/**
 * Created by wlc on 2018/4/9.
 */

/**
 * 全局变量
 */
//实验原料
var ExperimentMaterialArr;
var ExperimentMaterialsArr;

//通知栏
var notyf;

//图表
var CellChart = echarts.init(document.getElementById('Normal_cell_inhibitory_rate_chart'));
var TumorChart = echarts.init(document.getElementById('Tumor_cell_inhibition_rate_chart'));
var CalciumChart = echarts.init(document.getElementById('Intracellular_calcium_chart'));
var ROSChart = echarts.init(document.getElementById('ROS_chart'));
var ShrinkageChart = echarts.init(document.getElementById('Tumor_shrinkage_chart'));

/**
 * 变量与对象初始化
 */
window.onload = function (){
    //实验原料
    ExperimentMaterialsArr = new Array(0);

    //文件
    $('#SEM').filer({
        limit: 1,
        showThumbs: true,
        addMore: true,
        templates: {
            box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
            item: '<li class="jFiler-item">\
                    <div class="jFiler-item-container">\
                        <div class="jFiler-item-inner">\
                            <div class="jFiler-item-thumb">\
                                <div class="jFiler-item-status"></div>\
                                <div class="jFiler-item-info">\
                                    <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                    <span class="jFiler-item-others">{{fi-size2}}</span>\
                                </div>\
                                {{fi-image}}\
                            </div>\
                            <div class="jFiler-item-assets jFiler-row">\
                                <ul class="list-inline pull-left">\
                                    <li>{{fi-progressBar}}</li>\
                                </ul>\
                                <ul class="list-inline pull-right">\
                                    <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                </ul>\
                            </div>\
                        </div>\
                    </div>\
                </li>',
            itemAppend: '<li class="jFiler-item">\
                        <div class="jFiler-item-container">\
                            <div class="jFiler-item-inner">\
                                <div class="jFiler-item-thumb">\
                                    <div class="jFiler-item-status"></div>\
                                    <div class="jFiler-item-info">\
                                        <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                        <span class="jFiler-item-others">{{fi-size2}}</span>\
                                    </div>\
                                    {{fi-image}}\
                                </div>\
                                <div class="jFiler-item-assets jFiler-row">\
                                    <ul class="list-inline pull-left">\
                                        <li><span class="jFiler-item-others">{{fi-icon}}</span></li>\
                                    </ul>\
                                    <ul class="list-inline pull-right">\
                                        <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                    </ul>\
                                </div>\
                            </div>\
                        </div>\
                    </li>',
            itemAppendToEnd: false,
            removeConfirmation: true,
            _selectors: {
                list: '.jFiler-items-list',
                item: '.jFiler-item',
                remove: '.jFiler-item-trash-action'
            }
        },
        captions: {
            button: "上传",
            feedback: "",
            feedback2: "files were chosen",
            drop: "Drop file here to Upload",
            removeConfirmation: "确定移除文件?",
            errors: {
                filesLimit: "Only {{fi-limit}} files are allowed to be uploaded.",
                filesType: "Only frg are allowed to be uploaded.",
                filesSize: "{{fi-name}} is too large! Please upload file up to {{fi-maxSize}} MB.",
                filesSizeAll: "Files you've choosed are too large! Please upload files up to {{fi-maxSize}} MB."
            }
        }
    });
    $('#STM').filer({
        limit: 1,
        showThumbs: true,
        addMore: true,
        templates: {
            box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
            item: '<li class="jFiler-item">\
                    <div class="jFiler-item-container">\
                        <div class="jFiler-item-inner">\
                            <div class="jFiler-item-thumb">\
                                <div class="jFiler-item-status"></div>\
                                <div class="jFiler-item-info">\
                                    <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                    <span class="jFiler-item-others">{{fi-size2}}</span>\
                                </div>\
                                {{fi-image}}\
                            </div>\
                            <div class="jFiler-item-assets jFiler-row">\
                                <ul class="list-inline pull-left">\
                                    <li>{{fi-progressBar}}</li>\
                                </ul>\
                                <ul class="list-inline pull-right">\
                                    <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                </ul>\
                            </div>\
                        </div>\
                    </div>\
                </li>',
            itemAppend: '<li class="jFiler-item">\
                        <div class="jFiler-item-container">\
                            <div class="jFiler-item-inner">\
                                <div class="jFiler-item-thumb">\
                                    <div class="jFiler-item-status"></div>\
                                    <div class="jFiler-item-info">\
                                        <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                        <span class="jFiler-item-others">{{fi-size2}}</span>\
                                    </div>\
                                    {{fi-image}}\
                                </div>\
                                <div class="jFiler-item-assets jFiler-row">\
                                    <ul class="list-inline pull-left">\
                                        <li><span class="jFiler-item-others">{{fi-icon}}</span></li>\
                                    </ul>\
                                    <ul class="list-inline pull-right">\
                                        <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                    </ul>\
                                </div>\
                            </div>\
                        </div>\
                    </li>',
            itemAppendToEnd: false,
            removeConfirmation: true,
            _selectors: {
                list: '.jFiler-items-list',
                item: '.jFiler-item',
                remove: '.jFiler-item-trash-action'
            }
        },
        captions: {
            button: "上传",
            feedback: "",
            feedback2: "files were chosen",
            drop: "Drop file here to Upload",
            removeConfirmation: "确定移除文件?",
            errors: {
                filesLimit: "Only {{fi-limit}} files are allowed to be uploaded.",
                filesType: "Only frg are allowed to be uploaded.",
                filesSize: "{{fi-name}} is too large! Please upload file up to {{fi-maxSize}} MB.",
                filesSizeAll: "Files you've choosed are too large! Please upload files up to {{fi-maxSize}} MB."
            }
        }
    });

    $('#XRD').filer({
        limit: 1,
        showThumbs: true,
        addMore: true,
        templates: {
            box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
            item: '<li class="jFiler-item">\
                    <div class="jFiler-item-container">\
                        <div class="jFiler-item-inner">\
                            <div class="jFiler-item-thumb">\
                                <div class="jFiler-item-status"></div>\
                                <div class="jFiler-item-info">\
                                    <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                    <span class="jFiler-item-others">{{fi-size2}}</span>\
                                </div>\
                                {{fi-image}}\
                            </div>\
                            <div class="jFiler-item-assets jFiler-row">\
                                <ul class="list-inline pull-left">\
                                    <li>{{fi-progressBar}}</li>\
                                </ul>\
                                <ul class="list-inline pull-right">\
                                    <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                </ul>\
                            </div>\
                        </div>\
                    </div>\
                </li>',
            itemAppend: '<li class="jFiler-item">\
                        <div class="jFiler-item-container">\
                            <div class="jFiler-item-inner">\
                                <div class="jFiler-item-thumb">\
                                    <div class="jFiler-item-status"></div>\
                                    <div class="jFiler-item-info">\
                                        <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                        <span class="jFiler-item-others">{{fi-size2}}</span>\
                                    </div>\
                                    {{fi-image}}\
                                </div>\
                                <div class="jFiler-item-assets jFiler-row">\
                                    <ul class="list-inline pull-left">\
                                        <li><span class="jFiler-item-others">{{fi-icon}}</span></li>\
                                    </ul>\
                                    <ul class="list-inline pull-right">\
                                        <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                    </ul>\
                                </div>\
                            </div>\
                        </div>\
                    </li>',
            itemAppendToEnd: false,
            removeConfirmation: true,
            _selectors: {
                list: '.jFiler-items-list',
                item: '.jFiler-item',
                remove: '.jFiler-item-trash-action'
            }
        },
        captions: {
            button: "上传",
            feedback: "",
            feedback2: "files were chosen",
            drop: "Drop file here to Upload",
            removeConfirmation: "确定移除文件?",
            errors: {
                filesLimit: "Only {{fi-limit}} files are allowed to be uploaded.",
                filesType: "Only frg are allowed to be uploaded.",
                filesSize: "{{fi-name}} is too large! Please upload file up to {{fi-maxSize}} MB.",
                filesSizeAll: "Files you've choosed are too large! Please upload files up to {{fi-maxSize}} MB."
            }
        }
    });


    //通知栏
    notyf = new Notyf();

    //实验原料导入对话框
    $.ajax({
        url: 'experiment_material_acquisition' ,
        type: 'GET',
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (returndata) {
            for (var materialClass in returndata){
                var materialArr = returndata[materialClass].split("wlcniubi");
                var ul = $('<ul></ul>')[0];
                $('#'+materialClass)[0].appendChild(ul);
                for (var i=0;i<materialArr.length;i++){
                    ul.appendChild($('<li>'+materialArr[i]+'</li>')[0]);
                }
            }
            notyf.confirm("实验原料加载成功！");
        },
        error: function (returndata) {
            notyf.alert("实验原料加载失败，请联系管理员！");
        }
    });

    //图表
    var option1 = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        legend: {
            data:['抑制率','浓度']
        },
        xAxis: [
            {
                type: 'category',
                data: [],
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '抑制率',
                min: 0,
                max: 100,
                interval: 20,
                axisLabel: {
                    formatter: '{value} %'
                }
            },
            {
                type: 'value',
                name: '浓度',
                min: 0,
                max: 25,
                interval: 5,
                axisLabel: {
                    formatter: '{value} μg/ml'
                }
            }
        ],
        series: [
            {
                name:'抑制率',
                type:'bar',
                data:[]
            },
            {
                name:'浓度',
                type:'bar',
                data:[]
            }
        ]
    };
    var option2 = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        legend: {
            data:['细胞内钙量','材料浓度']
        },
        xAxis: [
            {
                type: 'category',
                data: [],
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '细胞内钙量',
                min: 0,
                max: 100,
                interval: 20,
                axisLabel: {
                    formatter: '{value} %'
                }
            },
            {
                type: 'value',
                name: '材料浓度',
                min: 0,
                max: 25,
                interval: 5,
                axisLabel: {
                    formatter: '{value} μg/ml'
                }
            }
        ],
        series: [
            {
                name:'细胞内钙量',
                type:'bar',
                data:[]
            },
            {
                name:'材料浓度',
                type:'bar',
                data:[]
            }
        ]
    };
    var option3 = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        legend: {
            data:['ROS增加量','材料浓度']
        },
        xAxis: [
            {
                type: 'category',
                data: [],
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: 'ROS增加量',
                min: 0,
                max: 100,
                interval: 20,
                axisLabel: {
                    formatter: '{value} %'
                }
            },
            {
                type: 'value',
                name: '材料浓度',
                min: 0,
                max: 25,
                interval: 5,
                axisLabel: {
                    formatter: '{value} μg/ml'
                }
            }
        ],
        series: [
            {
                name:'ROS增加量',
                type:'bar',
                data:[]
            },
            {
                name:'材料浓度',
                type:'bar',
                data:[]
            }
        ]
    };
    var option4 = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        legend: {
            data:['肿瘤缩小体积','浓度']
        },
        xAxis: [
            {
                type: 'category',
                data: [],
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '肿瘤缩小体积',
                min: 0,
                max: 100,
                interval: 20,
                axisLabel: {
                    formatter: '{value} %'
                }
            },
            {
                type: 'value',
                name: '浓度',
                min: 0,
                max: 25,
                interval: 5,
                axisLabel: {
                    formatter: '{value} μg/ml'
                }
            }
        ],
        series: [
            {
                name:'肿瘤缩小体积',
                type:'bar',
                data:[]
            },
            {
                name:'浓度',
                type:'bar',
                data:[]
            }
        ]
    };
    //正常细胞抑制率图表
    CellChart.setOption(option1);
    //肿瘤细胞抑制率图表
    TumorChart.setOption(option1);
    //细胞内钙量图表
    CalciumChart.setOption(option2);
    //ROS图表
    ROSChart.setOption(option3);
    //肿瘤体积缩小图表
    ShrinkageChart.setOption(option4);

    //图片信息样式
    $('.picture_info').attr("style","position:absolute");

    //表格输入框占位符
    $('#Normal_cell_inhibitory_rate').attr("placeholder","每一行为一条数据，数据之间用逗号隔开，数据顺序依次是：时间，抑制率，浓度。\n 例如：2,3,4");
    $('#Tumor_cell_inhibition_rate').attr("placeholder","每一行为一条数据，数据之间用逗号隔开，数据顺序依次是：时间，抑制率，浓度。\n 例如：2,3,4");
    $('#Intracellular_calcium').attr("placeholder","每一行为一条数据，数据之间用逗号隔开，数据顺序依次是：时间，细胞内钙量，材料浓度。\n 例如：2,3,4");
    $('#ROS').attr("placeholder","每一行为一条数据，数据之间用逗号隔开，数据顺序依次是：时间，ROS增加量，材料浓度。\n 例如：2,3,4");
    $('#Tumor_shrinkage').attr("placeholder","每一行为一条数据，数据之间用逗号隔开，数据顺序依次是：时间，肿瘤缩小体积，浓度。\n 例如：2,3,4");
};

/**
 * 对话框初始化
 */
//实验原料添加对话框
$('#Experimental_materialsAdd_modal').on('show.bs.modal', function (event) {
    var modal = $(this);
    var table = document.getElementById('t_element');
    var tbody = table.children[1];
    var childrenNum = tbody.children.length;
    for (var i = 0;i < childrenNum;i++){
        tbody.removeChild(tbody.children[0]);
    }
    modal.find('.modal-body input').val("");
    ExperimentMaterialArr = new Array(18);
});
$('#Elements_added').on('show.bs.modal', function (event) {
    var modal = $(this);
    modal.find('.modal-body input').val("");
});

/**
 *实验原料添加对话框处理
 */
$(document).on("click",'#Elements_added .modal-footer .btn-primary', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var element = $('#Elements_added .modal-body #element')[0].value;
    var num = $('#Elements_added .modal-body #element_num')[0].value;
    var enough;
    for (var i=1;i<10;i=i+2){
        if (isEmpty(ExperimentMaterialArr[i])){
            if (!isEmpty(element) && !isEmpty(num)){
                ExperimentMaterialArr[i] = element;
                ExperimentMaterialArr[i+1] = num;
                <!-- 创建表格一行 -->
                var table = document.getElementById('t_element');
                var tbody = table.children[1];
                var tr = document.createElement('tr');
                for(var j=0; j<2; j++){
                    var td = document.createElement('td');
                    var span = document.createElement('span');
                    span.appendChild(document.createTextNode(ExperimentMaterialArr[i+j]));
                    td.appendChild(span);
                    tr.appendChild(td);
                }
                tbody.appendChild(tr);
            }
            enough = false;
            break;
        }else {
            enough = true;
        }
    }
    if (enough){
        alert("能添加的元素已满！");
    }
});
$(document).on("click",'#Experimental_materialsAdd_modal .modal-footer .btn-primary', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    if (ExperimentMaterialsArr.length !== 72){
        var Charge = $('#Experimental_materialsAdd_modal .modal-body #Charge')[0].value;
        var abbreviation = $('#Experimental_materialsAdd_modal .modal-body #abbreviation')[0].value;
        var supplier = $('#Experimental_materialsAdd_modal .modal-body #supplier')[0].value;
        var Ratio = $('#Experimental_materialsAdd_modal .modal-body #Ratio')[0].value;
        var concentration_val = $('#Experimental_materialsAdd_modal .modal-body #concentration_val')[0].value;
        var concentration_unit = $('#Experimental_materialsAdd_modal .modal-body #concentration_unit')[0].value;
        isEmpty(Charge)?Charge = "null":ExperimentMaterialArr[11] = Charge;
        isEmpty(abbreviation)?abbreviation = "null":ExperimentMaterialArr[12] = abbreviation;
        isEmpty(supplier)?supplier = "null":ExperimentMaterialArr[13] = supplier;
        isEmpty(Ratio)?Ratio = "null":ExperimentMaterialArr[14] = Ratio;
        isEmpty(concentration_val)?concentration_val = "null":ExperimentMaterialArr[16] = concentration_val;
        isEmpty(concentration_unit)?concentration_unit = "null":ExperimentMaterialArr[17] = concentration_unit;
        <!-- 存储数据 -->
        ExperimentMaterialsArr = ExperimentMaterialsArr.concat(ExperimentMaterialArr);

        <!-- 创建表格一行 -->
        var table = document.getElementById('components');
        var tbody = table.children[1];
        var ele_num = 0;
        for(var i=2; i<=10;i = i + 2){
            if (!isEmpty(ExperimentMaterialArr[i])){
                ele_num = ele_num + parseInt(ExperimentMaterialArr[i]);
            }
        }
        var tr = document.createElement('tr');
        var td = document.createElement('td');
        var span = document.createElement('span');
        span.appendChild(document.createTextNode(ExperimentMaterialArr.slice(1,11).join("")));
        td.appendChild(span);
        tr.appendChild(td);
        var td = document.createElement('td');
        var span = document.createElement('span');
        span.appendChild(document.createTextNode(ele_num));
        td.appendChild(span);
        tr.appendChild(td);
        for(var j=0; j<4; j++){
            var td = document.createElement('td');
            var span = document.createElement('span');
            span.appendChild(document.createTextNode(ExperimentMaterialArr[j+11]));
            td.appendChild(span);
            tr.appendChild(td);
        }
        tbody.appendChild(tr);
    }else {
        alert("实验原料添加已满!");
    }
});

/**
 * 实验原料更新
 */
function updateExperimentMaterial(data) {
    var tempArr = data.split("wlcniubi");
    $('#experimental_materialsName')[0].value = tempArr[0];
    tempArr.shift();
    ExperimentMaterialsArr = tempArr;
    updateExperimentMaterialTable(ExperimentMaterialsArr);
}


/**
 * 实验原料删除
 */
$(document).on("click",'#experimental_materials_delete', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    if (ExperimentMaterialsArr.length !== 0){
        ExperimentMaterialsArr = new Array(0);
        updateExperimentMaterialTable(ExperimentMaterialsArr);
        notyf.confirm("实验原料删除成功！");
    }else {
        alert("实验原料为空，不用删除！");
    }
});

/**
 * 实验原料表格更新
 */
function updateExperimentMaterialTable(Arr) {
    var table = document.getElementById('components');
    var tbody = table.children[1];
    tbody.innerHTML = "";
    for (var i=0;i<Arr.length/18;i++){
        var temp_ExperimentMaterialArr = Arr.slice(i*18,(i+1)*18);

        var tr = document.createElement('tr');
        var td = document.createElement('td');
        var span = document.createElement('span');
        span.appendChild(document.createTextNode(temp_ExperimentMaterialArr[0]));
        td.appendChild(span);
        tr.appendChild(td);
        var ele_num = 0;
        for(var j=2; j<=10;j = j + 2){
            if (!isEmpty(temp_ExperimentMaterialArr[j])){
                ele_num = ele_num + parseInt(temp_ExperimentMaterialArr[j]);
            }
        }
        var td = document.createElement('td');
        var span = document.createElement('span');
        span.appendChild(document.createTextNode(ele_num));
        td.appendChild(span);
        tr.appendChild(td);
        for(var j=0; j<4; j++){
            var td = document.createElement('td');
            var span = document.createElement('span');
            span.appendChild(document.createTextNode(temp_ExperimentMaterialArr[j+11]));
            td.appendChild(span);
            tr.appendChild(td);
        }
        tbody.appendChild(tr);
    }
}

/**
 * 保存表单数据
 */
function saveExperiment(){
    var i = 0;
    var formData = new FormData();
//    part1
    var User_AND_Method = document.getElementsByClassName("part1");
    var User_AND_Method_str = "";
    for (i = 0;i<User_AND_Method.length;i++){
        if(User_AND_Method[i].value === ""){
            User_AND_Method_str = User_AND_Method_str + "null" + 'wlcniubi';
        }else {
            User_AND_Method_str = User_AND_Method_str + User_AND_Method[i].value + 'wlcniubi';
        }
    }
    formData.append("part1",User_AND_Method_str);
//    part2
    var ExperimentMaterialsArrLength = ExperimentMaterialsArr.length;
    for (i=0;i<(72-ExperimentMaterialsArrLength)/18;i++){
        ExperimentMaterialsArr = ExperimentMaterialsArr.concat(new Array(18));
    }
    ExperimentMaterialsArr.unshift($("#experimental_materialsName")[0].value);
    ExperimentMaterialsArr.push($("#experimental_materialsRemarks")[0].value);
    for (i=0;i<ExperimentMaterialsArr.length;i++){
        if (isEmpty(ExperimentMaterialsArr[i])){
            ExperimentMaterialsArr[i] = "null";
        }
    }
    formData.append("part2",ExperimentMaterialsArr.join("wlcniubi"));
//    part3
    i = 0;
    var Characterization = document.getElementsByName("EXPERIMENT_Characterization");
    var Characterization_str = "";
    for (;i<Characterization.length;i++){
        if(Characterization[i].value === ""){
            Characterization_str = Characterization_str + "null" + 'wlcniubi';
        }else {
            Characterization_str = Characterization_str + Characterization[i].value + 'wlcniubi';
        }
    }
    formData.append("part3",Characterization_str);
//    part4
    i = 0;
    var Biological_evaluation = document.getElementsByName("EXPERIMENT_Biological_evaluation");
    var Biological_evaluation_str = "";
    for (;i<Biological_evaluation.length;i++){
        if(Biological_evaluation[i].value === ""){
            Biological_evaluation_str = Biological_evaluation_str + "null" + 'wlcniubi';
        }else {
            Biological_evaluation_str = Biological_evaluation_str + Biological_evaluation[i].value + 'wlcniubi';
        }
    }
    Biological_evaluation_str += getCheckboxResult("Osteogenic_genes_in_vitro") + "wlcniubi"
        + getCheckboxResult("Osteogenic_genes_in_vivo") + "wlcniubi"
        + getCheckboxResult("Apoptosis_genes_in_vitro") + "wlcniubi"
        + getCheckboxResult("Apoptosis_genes_in_vivo") + "wlcniubi";
    formData.append("part4",Biological_evaluation_str);

    var semFile = $('#SEM')[0] .files.length > 0 ? $('#SEM')[0] .files[0] : new File([],"");
    var stmFile = $('#STM')[0] .files.length > 0 ? $('#STM')[0] .files[0] : new File([],"");
    formData.append("SEM_IMAGE",semFile);
    formData.append("STM_IMAGE",stmFile);
    $.ajax({
        url: 'data_save_experiment_EXPERIMENT' ,
        type: 'POST',
        data: formData,
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (returndata) {
            if (returndata === "success"){
                notyf.confirm("实验数据保存成功！");
            }else {
                notyf.alert("不能重复存储数据！");
            }
        },
        error: function (returndata) {
            notyf.alert("实验数据保存失败，请联系管理员！");
        }
    });
}

/**
 * 实验原料导入对话框原料选择点击
 */
$(document).on("click",'#Experimental_materialsImport_modal .tab-pane li', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var tableId = tar.parentNode.parentNode.id;
    var index = $('#'+tableId+' li').index(this);
    $.ajax({
        url: 'experiment_material_import' ,
        type: 'POST',
        data: {tableId:tableId,index:index},
        success: function (returndata) {
            updateExperimentMaterial(returndata);
            notyf.confirm("实验原料导入成功！");
        },
        error: function (returndata) {
            notyf.alert("实验原料获取失败，请联系管理员！");
        }
    });
});

/**
 * 正常细胞抑制率数据及图表更新
 */
$("#Normal_cell_inhibitory_rate").bind('input propertychange', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var option = CellChart.getOption();
    var dataArr = tar.value.split("\n");
    var hArr = [];
    var inRateArr = [];
    var conceArr = [];
    for (var i=0;i<dataArr.length;i++){
        hArr[i] = dataArr[i].split(",")[0]+"h";
        inRateArr[i] = dataArr[i].split(",")[1];
        conceArr[i] = dataArr[i].split(",")[2];
    }
    option.xAxis[0].data = hArr;
    option.series[0].data = inRateArr;
    option.series[1].data = conceArr;
    CellChart.setOption(option);
});

/**
 * 肿瘤细胞抑制率数据及图表更新
 */
$("#Tumor_cell_inhibition_rate").bind('input propertychange', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var option = TumorChart.getOption();
    var dataArr = tar.value.split("\n");
    var hArr = [];
    var inRateArr = [];
    var conceArr = [];
    for (var i=0;i<dataArr.length;i++){
        hArr[i] = dataArr[i].split(",")[0]+"h";
        inRateArr[i] = dataArr[i].split(",")[1];
        conceArr[i] = dataArr[i].split(",")[2];
    }
    option.xAxis[0].data = hArr;
    option.series[0].data = inRateArr;
    option.series[1].data = conceArr;
    TumorChart.setOption(option);
});

/**
 * 细胞内钙量图表数据及图表更新
 */
$("#Intracellular_calcium").bind('input propertychange', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var option = CalciumChart.getOption();
    var dataArr = tar.value.split("\n");
    var hArr = [];
    var inRateArr = [];
    var conceArr = [];
    for (var i=0;i<dataArr.length;i++){
        hArr[i] = dataArr[i].split(",")[0]+"h";
        inRateArr[i] = dataArr[i].split(",")[1];
        conceArr[i] = dataArr[i].split(",")[2];
    }
    option.xAxis[0].data = hArr;
    option.series[0].data = inRateArr;
    option.series[1].data = conceArr;
    CalciumChart.setOption(option);
});

/**
 * ROS数据及图表更新
 */
$("#ROS").bind('input propertychange', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var option = ROSChart.getOption();
    var dataArr = tar.value.split("\n");
    var hArr = [];
    var inRateArr = [];
    var conceArr = [];
    for (var i=0;i<dataArr.length;i++){
        hArr[i] = dataArr[i].split(",")[0]+"h";
        inRateArr[i] = dataArr[i].split(",")[1];
        conceArr[i] = dataArr[i].split(",")[2];
    }
    option.xAxis[0].data = hArr;
    option.series[0].data = inRateArr;
    option.series[1].data = conceArr;
    ROSChart.setOption(option);
});

/**
 * 肿瘤体积缩小数据及图表更新
 */
$("#Tumor_shrinkage").bind('input propertychange', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var option = ShrinkageChart.getOption();
    var dataArr = tar.value.split("\n");
    var hArr = [];
    var inRateArr = [];
    var conceArr = [];
    for (var i=0;i<dataArr.length;i++){
        hArr[i] = dataArr[i].split(",")[0]+"h";
        inRateArr[i] = dataArr[i].split(",")[1];
        conceArr[i] = dataArr[i].split(",")[2];
    }
    option.xAxis[0].data = hArr;
    option.series[0].data = inRateArr;
    option.series[1].data = conceArr;
    ShrinkageChart.setOption(option);
});

/**
 * 图片信息添加
 */
$(document).on("click",'.picture_info select', function(e){
    var evt=e||window.event;               //保证兼容性
    var tar=evt.target||evt.srcElement;  //获取触发事件的元素

    var parentId = tar.parentNode.id;
    switch (tar.value){
        case "球":
            $('#' + parentId + ' .info_input').remove();
            var element = $('<div class="info_input">' +
                '<input type="text" class="form-control" style="width: 110px" placeholder="直径">' +
                '</div>')[0];
            tar.parentNode.appendChild(element);
            break;
        case "棒/针/线":
            $('#' + parentId + ' .info_input').remove();
            var element = $('<div class="info_input">' +
                '<input type="text" class="form-control" style="width: 110px" placeholder="直径">' +
                '<input type="text" class="form-control" style="width: 110px" placeholder="长度">' +
                '</div>')[0];
            tar.parentNode.appendChild(element);
            break;
        case "立方/片":
            $('#' + parentId + ' .info_input').remove();
            var element = $('<div class="info_input"><input type="text" class="form-control" style="width: 110px" placeholder="宽度">' +
                '<input type="text" class="form-control" style="width: 110px" placeholder="长度">' +
                '<input type="text" class="form-control" style="width: 110px" placeholder="高度">' +
                '</div>')[0];
            tar.parentNode.appendChild(element);
            break;
        case "形状选择":
            $('#' + parentId + ' .info_input').remove();
            break;
    }
});